package com.jackeys.piaems.dto;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @ClassName: PaymentDetail
 * @Description: 账单详情数据传输类
 * @Author: Jackeys
 * @Date: 2021-06-17 20:16
 * @Version: 1.0
 */
@Data
public class PaymentDetailDto implements Serializable {
    /**
     * id
     */
    private Long id;
    /**
     * 收支id
     */
    private Long userId;
    /**
     * 分类id
     */
    private Long categoryId;
    /**
     * 日期
     */
    private Date date;
    /**
     * 单笔花费
     */
    private Float cost;
    /**
     * 备注
     */
    private String remark;
    /**
     * 标记收入与支出
     */
    private Integer flag;

    /**
     * 具体时间
     */
    private Date detailTime;

    /**
     * 分类名称
     */
    private String categoryName;

    public PaymentDetailDto(){}

    private PaymentDetailDto(Builder builder){
        this.id=builder.id;
        this.userId=builder.userId;
        this.categoryId=builder.categoryId;
        this.date=builder.date;
        this.cost=builder.cost;
        this.remark=builder.remark;
        this.flag=builder.flag;
        this.detailTime=builder.detailTime;
        this.categoryName=builder.categoryName;
    }

    /**
     * 构建者模式构建对象
     */
    public static final class Builder{
        private Long id;
        private Long userId;
        private Long categoryId;
        private Date date;
        private Float cost;
        private String remark;
        private Integer flag;
        private Date detailTime;
        private String categoryName;

        public Builder id(Long id){
            this.id=id;
            return this;
        }
        public Builder userId(Long userId){
            this.userId=userId;
            return this;
        }
        public Builder categoryId(Long categoryId){
            this.categoryId=categoryId;
            return this;
        }
        public Builder Date(Date date){
            this.date=date;
            return this;
        }
        public Builder cost(Float cost){
            this.cost=cost;
            return this;
        }
        public Builder remark(String remark){
            this.remark=remark;
            return this;
        }
        public Builder flag(Integer flag){
            this.flag=flag;
            return this;
        }

        public Builder detailTime(Date detailTime){
            this.detailTime=detailTime;
            return this;
        }

        public Builder  categoryName(String categoryName){
            this.categoryName=categoryName;
            return this;
        }
        //使用构建者创建PaymentDetail对象
        public PaymentDetailDto build() {
            return new PaymentDetailDto(this);
        }
    }
}
